package com.example.service1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @className: controller
 * @description:
 * @author: yang pan
 */
@RestController
@RefreshScope
public class Controller {

    @Autowired
    private Environment environment;
    @Value("${user.name}")
    private String userame;
    @Value("${user.mobile}")
    private String mobile;

    @RequestMapping("/getUser")
    public String getUserFromConfig(){

        return  "用户名: "+ userame + "电话: " +   mobile;
    }


    public static Map<String,String>  userMap = new HashMap<>();
    static {
        userMap.put("1", "用户名: 杨攀 电话 12345678910");
    }
    @RequestMapping("/getUserInfo")
    public String getUserInfo(String userId){

        return  userMap.get(userId);
    }
}
